Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement new tendency diagnostics package and significant revisions to PV diagnostics package in MPAS-A #1211

Open
wants to merge 23 commits into
base: develop
Choose a base branch
from

Conversation

theweathermanda
Copy link
Contributor

This PR includes a series of commits that progressively lead to the implementation of a new tendencies diagnostics package and a significantly revised PV diagnostics package for MPAS-Atmosphere, as described further in issue #1201.

The new tendency diagnostics package was created by May Wong (@maywswong) and tracks model tendencies throughout the integration in order to evaluate budgets of variables such as potential temperature and momentum. The revised PV tendency diagnostics package is now largely dependent on the tendency diagnostics package for calculations of tendencies that are used in the PV tendency and budget calculations. Additionally, the revised PV package includes several new features, including accumulating the PV tendencies throughout the model integration and calculating the PV tendencies from individual processes in the Thompson microphysics scheme. The revised PV tendency package is described in more detailed here.

Collectively, both of these packages require a large number of new model variables and calculations. To address this, we have added several namelist config_* flags that are connected to variable packages to (1) make it easy for the user community to toggle on/off these diagnostic calculations at run-time and (2) reduce the memory and computational resources required to run the model when these packages are disabled:
config_tend: calculations and variables associated with tendency diagnostics package
config_pv_diag: calculation of ertel_pv and DT interpolation of model state variables
config_pv_tend: calculation of instantaneous and accumulated PV tendencies
config_pv_microphys: calculation of PV tendencies from individual microphysical processes
config_pv_scalar: transport of PV passive scalar variable
config_pv_isobaric: interpolation of PV diagnostic variables to isobaric levels

Due to the dependence of later features on earlier commits, I think it's best to keep these code changes under the umbrella of a single pull request to avoid multiple PRs containing the same set of commits. However, the commits will still follow the proposed ordering of (1) adding the framework for the tendency and PV diagnostics packages, (2) implementing the tendency diagnostics package, and (3) implementing the revised PV tendency diagnostics package, with possible bug fixes interspersed. For the PV diagnostics package portion, the commits will be ordered such that earlier commits will primarily revise the capabilities that already exist in mpas_pv_diagnostics.F, while later commits will add new features that aren't already in the code. Comments will be provided to further indicate whether the commits pertain to (1), (2), or (3).

- Add tendency and PV packages declarations to Registry.xml
- Add Registry_tendencies.xml file with tendency package variables
- Update Registry_diagnostics.xml with Registry_tendencies.xml and namelist config option declarations
- Update Registry_pv.xml with all variables required to make modifications to PV diagnostics package
… variable packages

- Added mpas_atm_diagnostics_packages.F in /src/core_atmosphere/diagnostics to setup the tendency and PV diagnostics packages based on config options and ensure comptability between the config options selected in the namelist
- Modified Makefile in /src/core_atmosphere/diagnostics to reflect this new script
- Modified mpas_atm_core_interface.F to call mpas_atm_diagnostics_packages.F to setup these packages
- Updated mpas_atm_halos.F with new halo groups for GWDO tendencies and horizontal momentum tendencies
- Updated mpas_atmphys_todynamics.F to include physics tendency diagnostic calculations
- Updated mpas_atmphys_interface.F to include microphysics tendency diagnostic calculations
- Updated mpas_atm_time_integration.F to include calculations and subroutines for tendency diagnostics
- Removed extraneous variables
- Changed descriptions to specify tendencies of moist potential temperature
@theweathermanda
Copy link
Contributor Author

The above commits a6eeee, 47d1203, and 7622e5d establish the framework for the two diagnostics packages [objective (1)]. Commit 022000f contains the code implementation of May Wong's tendency diagnostics package, with a needed reordering of the timer calls (bug fix) in 7622e5d [objective (2)].

- Modified mpas_atm_halos.F to include halo groups for variables used in PV calculations:

  For ertel_pv:
  -- diagnostics:pv_diag

  For DT identification:
  -- diagnostics:inStrato (integer fields currently unsupported for mpas_halo_exch_group)
  -- diagnostics:inTropo (integer fields currently unsupported for mpas_halo_exch_group)
  -- diagnostics:iLev_DT (integer fields currently unsupported for mpas_halo_exch_group)

  For PV tendencies:
  -- diagnostics:dpv_prev
  -- diagnostics:dpv_th_tend
  -- diagnostics:dpv_mom_tend
  -- diagnostics:dpv_mom_curl

  For microphysics PV tendencies:
  -- diagnostics:dpv_mp_tend

- Starting from scratch, recreated mpas_pv_diagnostics.F and implemented subroutines to calculate
  ertel_pv, identify the dynamic tropopause, and interpolate static fields to the DT

- Adapted relevant subroutines in mpas_pv_diagnostics.F to use new halo communication groups. The
  approach I took was modeled after the few scripts in core_atmosphere that had already done this
  is and is possibly an overly complicated way of calling the needed arguments (like domain), which
  are ultimately passed down to the PV code from mpas_atm_core.F. Thus, code changes propagate up
  to that script and include modifications to the following:

  -- atm_compute_pv_diagnostics in mpas_pv_diagnostics.F
  -- pv_diagnostics_update and pv_diagnostics_compute in mpas_pv_diagnostics.F, called by
     mpas_atm_diagnostics_manager.F
  -- mpas_atm_diagnostics_manager.F to support changes to the PV subroutine calls and
     include input arguments to mpas_atm_diag_update and mpas_atm_diag_compute
  -- mpas_atm_core.F to support the new arguments called in mpas_atm_diag_update and
     mpas_atm_diag_compute

  Note that the DT identification routines in mpas_pv_diagnositcs.F require halo communication,
  but the communicated fields are integers and are thus currently incompatable with the new
  MPAS halo groups. I left these as-is.
@theweathermanda
Copy link
Contributor Author

Commit ae664a1 begins of the implementation of the revised PV diagnostics package [objective (3)] by recreating mpas_pv_diagnostics.F from scratch and including subroutines to calculate ertel_pv, identify the dynamic tropopause, and interpolate static fields to the dynamic tropopause. This commit does not include calculations of PV tendencies, which were in the original mpas_pv_diagnostics.F code. These will be included in the next commits.

Added calculation of rucuten_tend for tendency diagnostics package, which was missing.
- Added relevant subroutines to mpas_pv_diagnostics.F to store variables from the
  beginning of the time step and compute PV tendencies for all fundamental diabatic,
  dynamic, and frictional processes. Added subroutine to interpolate PV tendencies
  to DT identified at the beginning of the time step. Added subroutine to accumulate
  tendencies over successive time steps.

- Added call to pv_diagnostics_reset in mpas_atm_diagnostics_manager.F

- Modified mpas_atmphys_interface.F to add calculations of thmmpten and qvmppten and
  remove calculations of dtheta_dt_mp, which is now calculated in the PV script.

  Note: v8.2.0 now contains calculations of rthmpten and rqvmpten for some microphysics schemes.
  rqvmpten is equal to qvmmpten, but rthmpten (theta tendency, not theta-m tendency) will
  not exactly equal the theta tendency derived from thmmpten and qvmppten that results in a
  closed theta budget (dtheta_dt_mp).

- Added outstanding tendency calculations used for PV tendencies to mpas_atm_time_integration.F
  and initialized du_dt_dyn as 0. Also added missing calculation for ru_tend_diff that is
  needed for the ITM package but was omitted in a prior commit.

- Modified mpas_atm_todynamics.F to remove calculations of tend_u_phys, which is no
  longer used in the PV tendency calculations.

- Modified mpas_atm_core.F to add a config_pv_tend flag for calculation of diagnostic
  variables, rho and theta. Previously these were only calculated prior to writing an
  output file. If config_pv_tend is set to true, these will now be calculated at
  each time step.
- This commit removes tend_u_phys from Registry_pv.xml. This variable is
  no longer used to compute the frictional PV tendency.
- Removed PV diagnostics variables from preexisting history output stream and
  created default pvbudget stream containing relevant variables
- Added pv_callCounter to Registry_pv.xml

- Added pv_callCounter tracking in mpas_pv_diagnostics.F to activate calculations
  of PV tendencies during runtime, not at model initialization. This is really only
  relevant for when the model is restarted and the derived parent tendencies used in the
  PV tendency calculations are inaccurate because (1) they are not included in restart
  streams and (2) mpas_atm_time_integration.F hasn't been called. This prevents the
  inaccurate tendencies from being included in the accumulated PV tendency variables

- Removed declaration of _dyn variables from mpas_atm_time_integration.F
@theweathermanda
Copy link
Contributor Author

theweathermanda commented Jul 9, 2024

Commits 64b09cd through 6796b74 contain code changes and additions for the implementation of PV tendency calculations in the PV diagnostics package [objective (3)]. These calculations use different process tendency variables than in the original PV diagnostics code and now rely heavily on tendencies calculated as part of May Wong's tendency diagnostic package that was implemented in prior commits.

- Added mpas_halo_exch_group_complete for microphysics process tendencies (was previously missing)

- Added tend_theta_mp_* variables to Registry.xml that track potential temperature tendencies for the following processes
  in the Thompson microphysics scheme: net condensation/evaporation of cloud water, evaporation of rain water,
  net deposition/sublimation, melting, and freezing. These variables are only computed for config_pv_microphys = .true.
  and are used in the calculation of PV tendencies for each respective process

- Added variable declarations to mpas_atmphys_vars.F for calculations of temperature tendencies from the Thompson scheme

- Added calculations of temperature and potential temperature tendencies to module_mp_thompson.F, mpas_atmphys_driver_microphys.F,
  and mpas_atmphys_interface.F

- Added calculations of PV tendencies associated with these specific microphysical processes to mpas_pv_diagnostics.F

- Added compatability with 'mp_thompson_aerosols' in Registry.xml and mpas_atm_diagnostics_packages.F
@theweathermanda
Copy link
Contributor Author

Commits 522452f through 4c8ce89 correspond to the implementation of potential temperature tendencies from specific microphysical processes in the Thompson scheme, which are used to calculate the corresponding PV tendencies in mpas_pv_diagnostics.F.

The microphysical PV tendencies are only computed when config_pv_microphys = True, which is disabled for microphysics other than Thompson or Thompson aerosol. The additional calculations in module_mp_thompson.F are only enabled for MPAS, but there is currently no dependence on user settings. Ideally all tend_theta_* and tend_temp_* variables and calculations would be set as optional and connected to the config_pv_microphys namelist runtime option.

  This commit pertains to a series of modifications that clean up
  to currently existing isobaric diagnostics interpolation. The
  existing diagnostics comprise a number of variables at individual
  pressure levels (e.g., temperature_200hPa) and thus require a significant
  amount of hard-coding.

  This modified version reduces (but does not eliminate) the need for
  hard-coding by prescribing a list of isobaric levels to which the
  variables are commonly interpolated, leading to variables of the form
  e.g., temperature_isobaric. These variables are also connected to a
  diagnostic package and namelist config option (config_isobaric = .true.)
  to make it easier for users to toggle on their calculation at runtime.

  The specific changes include:

  - Adding an isobaric package to Registry.xml

  - Adding the config_isobaric namelist option to Registry_diagnostics.xml

  - Connecting the package variables to the namelist option in mpas_atm_diagnostics_packages.F

  - Updating Registry_isobaric.xml to remove the highly specific variables and
    replace them with more generalizable variables, such as temperature_isobaric

  - Updating Registry.xml to change the default diagnostics stream variables

  - Updating mpas_isobaric_diagnostics.F with the interpolation of the new
    generalizable variables and removal of the old variables. Subroutines are
    also added to clean up the code.

  - Adding halo groups 'isobaric:pressure_p' and 'isobaric:vorticity' to
    mpas_atm_halos.F and removing the previous halo field exchanges from
    mpas_isobaric_diagnostics.F

  - Updating mpas_atm_diagnostics_manager.F to include the halo exchange
    and config input arguments to the isobaric subroutine calls
- Changed diagnostics option and config_isobaric to be in the default
  namelist configuration.
@theweathermanda
Copy link
Contributor Author

Commits c3fb0f8 and 5f53d23 contain the same code changes as PR #1184, which restructures the isobaric diagnostics code to make it cleaner, easier to modify, and less reliant on hard-coding. This also includes the definition of an isobaric diagnostics variable package, which is connected to a new config_isobaric namelist option.

These modifications to the isobaric diagnostics package will be extended to include the isobaric interpolation of PV diagnostics variables in later commits.

- Added intialization of pv_scalar field as ertel_pv to mpas_pv_diagnostics.F
- Added calls to initialize pv_scalar field to mpas_atm_diagnostics_manager.F and
  mpas_atm_core.F
- Added call to advect_scalars subroutine for pv_scalars in mpas_atm_time_integration.F
  if config_pv_scalar = True
@theweathermanda
Copy link
Contributor Author

Commit bfddf5e contains code to initialize an optional pv_scalar variable as ertel_pv at model initialization time and transport it as a passive scalar throughout the integration. This feature is tied to namelist runtime option config_pv_scalar.

- Add isobaric PV variables to Registry_isobaric.xml

- Add isobaric interpolation of PV and PV tendencies to mpas_isobaric_diagnostics.F

- Add calls to isobaric interpolation subroutines and accumulation of isobaric PV tendencies to mpas_pv_diagnostics.F

- Add config_pv_isobaric flag dependence on halo group for 'isobaric:pressure_p'
@theweathermanda
Copy link
Contributor Author

Commit 08b417c contains code to interpolate the PV variables to isobaric surfaces and accumulate the PV tendencies after interpolation. This is the final primary feature to be implemented as part of objective (3).

@theweathermanda theweathermanda changed the base branch from master to develop July 10, 2024 04:53
- Code previously did halo exchange of wCell before it was calculated,
  leading to erroneous values of ertel_pv along halo region boundaries
  when nCellsSolve is used in mpas_pv_diagnostics.F subroutines rather
  than nCells.

- Commit adds a separate halo group for wCell and calls this group
  in the calc_epv subroutine in mpas_pv_diagnostics.F
- Code previously did halo exchanges of intermediate wCell tendency variables
  before they were calculated, leading to erroneous values of depv_dt_fric and
  depv_dt_dyn along halo region boundaries when nCellsSolve is used in
  mpas_pv_diagnostics.F subroutines rather than nCells.

- Commit adds separate halo groups for the wCell tendencies and calls these groups
  in the calc_pvBudget subroutine in mpas_pv_diagnostics.F
@theweathermanda
Copy link
Contributor Author

Commits bea55b6 and e1157f3 contain important bug fixes that go along with the code changes and additions first introduced in commit ae664a1.

Commit b9c3ec4 contains a bug fix that corresponds to the introduction of PV tendency calculations in commit 64b09cd.

Additions:
- Add pv_scalar_dt variable to Registry.xml, which will be reset to the updated ertel_pv
  field at the end of each time step
- Add depv_dt_scalar_adv, acc_depv_dt_scalar_adv to track the PV tendencies from
  advecting PV as a scalar variable through pv_scalar_dt

Bug fixes:
- Add halo groups for pv_scalars at time levels 1 and 2 to mpas_atm_halos.F
- Add halo exchanges for pv_scalars to mpas_atm_time_integration.F
- Add advance_scalars option for pv_scalars when split scalar transport isn't selected
- Removed rk_step == 3 dependence on advance_scalars for pv_scalars
- Modified the dqv_dt_dyn, acc_dqv_dt_dyn calculations to be consistent with qv
  dynamics tendency for both monotonic and non-monotonic scalar transport
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants